package com.lxs;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class LocalDNSResolver {
    public static void main(String[] args) {
        try {
            // 解析局域网主机名
            InetAddress address = InetAddress.getByName("IT-zkrlihy1");
            System.out.println("IP地址: " + address.getHostAddress());
            System.out.println("主机名: " + address.getHostName());

            // 反向解析
            InetAddress reverse = InetAddress.getByName("192.168.1.50");
            System.out.println("反向解析: " + reverse.getHostName());

        } catch (UnknownHostException e) {
            System.out.println("无法解析主机: " + e.getMessage());
        }
    }
}
